﻿Public Class ViewParametrerTauxComFrais

    Private Sub BtSetCrt_Click(sender As Object, e As Windows.RoutedEventArgs) Handles BtSetCrt.Click
        Dim data As ViewModelParametrerTauxComFrais = DataContext
        Dim datamanager As New DataManager

        For Each drv As DataRowView In HistoCrtDgrid.SelectedItems

            Dim drow As DataModel.PmtDataset.CommissionsFrais_HistoCRTRow = drv.Row

            Dim r = datamanager.Dataset.CommissionsFrais.FindByGroupeGenerationCode_Garantie(drow.Groupe, drow.Generation, drow.Code_Garantie)

            If r Is Nothing Then
                datamanager.Dataset.CommissionsFrais.AddCommissionsFraisRow(drow.Groupe, drow.Code_Garantie, drow.Generation, drow.Taux_CBP, drow.Taux_BP, drow.Taux_SelectionMedicale)
            Else
                r.Taux_BP = drow.Taux_BP
                r.Taux_CBP = drow.Taux_CBP
                r.Taux_SelectionMedicale = drow.Taux_SelectionMedicale
            End If
        Next
    End Sub

    Private Sub Estimer_CRT_MenuItem_Click(sender As Object, e As Windows.RoutedEventArgs)
        Dim datamanager As New DataManager

        datamanager.Recalculer_Table_Taux_Com()
    End Sub
End Class
